package com.leaf.lowcode.datasend;

import com.alibaba.fastjson.JSON;
import com.hikvision.artemis.sdk.ArtemisHttpUtil;
import com.hikvision.artemis.sdk.config.ArtemisConfig;
import com.leaf.lowcode.entity.ResBean;

import java.util.HashMap;
import java.util.Map;

public class XGFunctionApi {
    /**
     * STEP1：设置平台参数，根据实际情况,设置host appkey appsecret 三个参数.
     */
    static {
        ArtemisConfig.host = "10.140.161.12:443";
        ArtemisConfig.appKey = "29544061"; // 秘钥appkey
        ArtemisConfig.appSecret = "N1Ims5vjYUTQIGdItUjc";
    }
    /**
     * STEP2：设置OpenAPI接口的上下文
     */
    private static final String ARTEMIS_PATH = "/artemis";

    //1.巡更路线查询
    public  String getRouteUpdate(ResBean resBean){
        String RouteUpdate = ARTEMIS_PATH +"/api/gtps/api/v1/route/records";
        Map<String,String> path = new HashMap<String,String>(2){
            {
                put("https://",RouteUpdate);
            }
        };
        String body= JSON.toJSONString(resBean);
        String result = ArtemisHttpUtil.doPostStringArtemis(path,body,null,null,"application/json");
        return result;
    }


    //2.查询巡更计划
    public  String getRoutePlan(ResBean resBean){
        String RoutePlan = ARTEMIS_PATH +"/api/gtps/api/v1/plan/records";
        Map<String,String> path = new HashMap<String,String>(2){
            {
                put("https://",RoutePlan);
            }
        };
        String body=JSON.toJSONString(resBean);
        String result =ArtemisHttpUtil.doPostStringArtemis(path,body,null,null,"application/json");
        return result;
    }

    //3.查询巡更结果
    public  String getRouteRes(ResBean resBean){
        String RouteRes = ARTEMIS_PATH +"/api/gtps/api/v1/patrolHistory/records";
        Map<String,String> path = new HashMap<String,String>(2){
            {
                put("https://",RouteRes);
            }
        };
        String body=JSON.toJSONString(resBean);
        String result =ArtemisHttpUtil.doPostStringArtemis(path,body,null,null,"application/json");
        return result;
    }
//4.查询巡更结果详情
    public String getRouteResDetail(ResBean resBean){
        String RouteResDetail = ARTEMIS_PATH +"/api/gtps/api/v1/historyDetailInfo/records";
        Map<String,String> path = new HashMap<String,String>(2){
            {
                put("https://",RouteResDetail);
            }
        };
        String body=JSON.toJSONString(resBean);
        String result =ArtemisHttpUtil.doPostStringArtemis(path,body,null,null,"application/json");
        return result;
    }
}
